/*
 * Copyright 2024 Harness, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const adjectives = [
  'admiring',
  'adoring',
  'affectionate',
  'agitated',
  'amazing',
  'angry',
  'awesome',
  'beautiful',
  'blissful',
  'bold',
  'boring',
  'brave',
  'busy',
  'charming',
  'clever',
  'compassionate',
  'competent',
  'condescending',
  'confident',
  'cool',
  'cranky',
  'crazy',
  'dazzling',
  'determined',
  'distracted',
  'dreamy',
  'eager',
  'ecstatic',
  'elastic',
  'elated',
  'elegant',
  'eloquent',
  'epic',
  'exciting',
  'fervent',
  'festive',
  'flamboyant',
  'focused',
  'friendly',
  'frosty',
  'funny',
  'gallant',
  'gifted',
  'goofy',
  'gracious',
  'great',
  'happy',
  'hardcore',
  'heuristic',
  'hopeful',
  'hungry',
  'infallible',
  'inspiring',
  'intelligent',
  'interesting',
  'jolly',
  'jovial',
  'keen',
  'kind',
  'laughing',
  'loving',
  'lucid',
  'magical',
  'modest',
  'musing',
  'mystifying',
  'naughty',
  'nervous',
  'nice',
  'nifty',
  'nostalgic',
  'objective',
  'optimistic',
  'peaceful',
  'pedantic',
  'pensive',
  'practical',
  'priceless',
  'quirky',
  'quizzical',
  'recursing',
  'relaxed',
  'reverent',
  'romantic',
  'sad',
  'serene',
  'sharp',
  'silly',
  'sleepy',
  'stoic',
  'strange',
  'stupefied',
  'suspicious',
  'sweet',
  'tender',
  'thirsty',
  'trusting',
  'unruffled',
  'upbeat',
  'vibrant',
  'vigilant',
  'vigorous',
  'wizardly',
  'wonderful',
  'xenodochial',
  'youthful',
  'zealous',
  'zen'
]

const superheroes = [
  'aquaman',
  'artemis',
  'atom',
  'bane',
  'batgirl',
  'batman',
  'beast',
  'beastboy',
  'bishop',
  'blackadam',
  'blackbolt',
  'blackcat',
  'blackpanther',
  'blackwidow',
  'blade',
  'bluebeetle',
  'boostergold',
  'bucky',
  'cable',
  'captainamerica',
  'captainbritain',
  'captaincold',
  'captainmarvel',
  'catwoman',
  'colossus',
  'constantine',
  'cyclops',
  'cyborg',
  'daredevil',
  'darkseid',
  'deadpool',
  'deathstroke',
  'doctordoom',
  'docktormanhattan',
  'doctorstrange',
  'dominos',
  'doomsday',
  'drax',
  'elektra',
  'emmafrost',
  'enchantress',
  'falcon',
  'firestorm',
  'flash',
  'gamora',
  'ghostrider',
  'greenarrow',
  'greenlantern',
  'grodd',
  'groot',
  'guardian',
  'havok',
  'hawkeye',
  'hawkgirl',
  'hawkman',
  'hela',
  'hellboy',
  'hitgirl',
  'hobogoblin',
  'hogan',
  'hopesummers',
  'hulk',
  'humantorch',
  'iceman',
  'ironfist',
  'ironheart',
  'ironman',
  'jessicajones',
  'joker',
  'juggernaut',
  'karnak',
  'kidflash',
  'kilowog',
  'kingpin',
  'kittypryde',
  'kraven',
  'ladydeathstrike',
  'lexluthor',
  'lifedeath',
  'lobo',
  'loki',
  'lucifer',
  'lukecage',
  'magik',
  'magneto',
  'manbat',
  'martianmanhunter',
  'medusa',
  'meggan',
  'milesmorales',
  'misterfreeze',
  'mistermiracle',
  'mistyknight',
  'moonknight',
  'morbius',
  'msmarvel',
  'mystique',
  'namor',
  'nightcrawler',
  'nightwing',
  'nikominoru',
  'nickfury',
  'nova',
  'ocelot',
  'omegared',
  'oracle',
  'peacemaker',
  'penguin',
  'phoenix',
  'poisonivy',
  'polaris',
  'professorx',
  'punisher',
  'quasar',
  'quicksilver',
  'rachelsummers',
  'raven',
  'redhood',
  'redskull',
  'rhino',
  'riddler',
  'robin',
  'rocketraccoon',
  'rogue',
  'sabretooth',
  'sandman',
  'scarletspider',
  'scarletwitch',
  'scorpion',
  'sentry',
  'shadowcat',
  'shangchi',
  'shazam',
  'shehulk',
  'silversable',
  'silversurfer',
  'sinister',
  'spawn',
  'spectre',
  'spiderman',
  'spiderman2099',
  'squirrelgirl',
  'starfire',
  'stargirl',
  'starlord',
  'steppenwolf',
  'storm',
  'superboy',
  'supergirl',
  'superman',
  'swampthing',
  'symbiotespidey',
  'taskmaster',
  'thanos',
  'thething',
  'thor',
  'thunderbird',
  'tigra',
  'timdrake',
  'twoface',
  'ultron',
  'valkyrie',
  'venom',
  'vision',
  'vixen',
  'vulcan',
  'wallywest',
  'wasp',
  'warlock',
  'warmachine',
  'wiccan',
  'wolverine',
  'wonderman',
  'wonderwoman',
  'x23',
  'yondu',
  'zatanna',
  'zod',
  'zoom',
  'dazzler',
  'silk',
  'blackknight',
  'moonstar',
  'manhunter',
  'madrox',
  'cannonball',
  'sunspot',
  'pyro',
  'armor',
  'jubilee',
  'dust',
  'forge',
  'siryn',
  'longshot',
  'karma',
  'thunderstrike',
  'hellcat',
  'cloak',
  'dagger'
]

export function generateGitspaceName(): string {
  const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]
  const superhero = superheroes[Math.floor(Math.random() * superheroes.length)]
  return `${adjective}-${superhero}`
}

export function getIdentifierFromName(name?: string) {
  if (!name) return name
  const filteredName = name.replace(/[^a-zA-Z0-9-]/g, '')
  return filteredName
}
